package com.etone.web.controller.system;

import com.etone.common.annotation.Anonymous;
import com.etone.common.annotation.Log;
import com.etone.common.core.domain.AjaxResult;
import com.etone.common.enums.BusinessType;
import com.etone.system.domain.TurnoverInventory;
import com.etone.system.service.ITurnoverInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Anonymous
@RequestMapping("/turnoverInventory")
public class TurnoverInventoryController {
    @Autowired
    private ITurnoverInventoryService turnoverInventoryservice;

    /**
     * 记录入库物料与仓位绑定记录
     * @param list
     * @return
     */
    @RequestMapping("/addTurnoverInventory")
    @Log(title = "绑定入库仓位与物料",businessType = BusinessType.INSERT)
    public AjaxResult addTurnoverInventory(@RequestBody List<TurnoverInventory> list){
        return AjaxResult.success(turnoverInventoryservice.addTurnoverInventory(list));
    }

    /**
     * 查询绑定记录
     * @param page
     * @param pageSize
     * @param wuliaoNo
     * @return
     */
    @RequestMapping("/selectTurnoverInventoryList")
    public AjaxResult selectTurnoverInventoryList(@RequestParam(value = "page") int page,
                                                  @RequestParam(value = "pageSize") int pageSize,
                                                  @RequestParam(value = "wuliaoNo",required = false) String wuliaoNo,
                                                  @RequestParam(value = "status",required = false) int status){
        return AjaxResult.success(turnoverInventoryservice.selectTurnoverInventoryList(page,pageSize,wuliaoNo,status));
    }

    /**
     * 查看货位表情况
     * @return
     */
    @RequestMapping("/selectSysStorageList")
    public AjaxResult selectSysStorageList(){
        return AjaxResult.success(turnoverInventoryservice.selectSysStorageList());
    }

    /**
     * 记录出库物料与仓位绑定记录
     * @param list
     * @return
     */
    @RequestMapping("/addTurnoverOutbound")
    @Log(title = "绑定入库仓位与物料",businessType = BusinessType.INSERT)
    public AjaxResult addTurnoverOutbound(@RequestBody List<TurnoverInventory> list){
        return AjaxResult.success(turnoverInventoryservice.addTurnoverOutbound(list));
    }

    /**
     * 记录入库物料与仓位绑定记录(加急出库)
     * @param list
     * @return
     */
    @RequestMapping("/urgentTurnoverOutbound")
    @Log(title = "绑定入库仓位与物料",businessType = BusinessType.INSERT)
    public AjaxResult urgentTurnoverOutbound(@RequestBody List<TurnoverInventory> list){
        return AjaxResult.success(turnoverInventoryservice.urgentTurnoverOutbound(list));
    }

    /**
     * 空箱子搬运回出库周转区
     */
    @RequestMapping("/boxBack")
    public AjaxResult boxBack(@RequestParam(value = "cangweiNo") String cangweiNo){
        return AjaxResult.success(turnoverInventoryservice.boxBack(cangweiNo));
    }

    /**
     * 坏的物料码绑定周转货架去入库周转区
     * @param list
     * @return
     */
    @RequestMapping("/badBack")
    @Log(title = "绑定入库仓位与物料",businessType = BusinessType.INSERT)
    public AjaxResult badBack(@RequestBody List<TurnoverInventory> list){
        return AjaxResult.success(turnoverInventoryservice.badBack(list));
    }
}
